clear
clear mata
clear matrix

capture log close
log using "APST_replication tables.log", replace

******************************************************************************

*       Replication file for "Agricultural Productivity and Structural Transformation"
*               by Paula Bustos, Bruno Caprettini and Jacopo Ponticelli

*       FIRST VERSION   March      31, 2015
*       THIS VERSION    December   15, 2015


*       LAST REVISOR		BC
		
*	    This file reproduces and exports all regressions included in the paper:
*               "Agricultural Productivity and Structural Transformation"
*       Forthcoming on the American Economic Review.

*       Note: all tables and regressions are produced using the APST_AMC.dta database except:
*             - Table  1: aggregate statistics from Agricultural Census.
*             - Table A7: robustness check with regressions at microregion level
*             - Table A9: robustness check with data from firm-level databases (PIA)
*       Replication code for table A7 is at the bottom of this file, where the procedure uploads the APST_micro.dta database
*       Table 1 is not replicated here, as the statistics come directly from Agricultural Censuses publications (see paper for details)
*       For Table A9 we report the code needed to run the regressions. However, the PIA data can not be distributed and must be accessed on IBGE premises.
*******************************************************************************


****************************************************************************************************
****                                   PLAN OF THE PROCEDURE                                    ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
****                                                                                            ****
****____________________________________________________________________________________________****
**** Results with data at AMC level:                                                            ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
****                                     Baseline Results                                       ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
**** Table  1: Land use and labor intensity by agricultural activity                            ****
**** Table  2: Summary Statistics of main variables at municipality level                       ****
**** Table  3: Basic correlation in the data: agriculture                                       ****
**** Table  4: Basic correlation in the data: manufacturing                                     ****
**** Table  5: Comparing Municipalities below/above median increase in potential soy yield      ****
**** Table  6: The effect of technological change on agriculture. GE soy adoption               ****
**** Table  7: The effect of technological change on agriculture. Soy and maize expansion       ****
**** Table  8: The effect of technological change on agriculture                                ****
****           Productivity, labor intensity and employment share                               ****
**** Table  9: The effect of agricultural technological change on manufacturing                 ****
****           Employment share, employment and wages                                           ****
**** Table 10: The effect of agricultural technological change on employment shares             ****
**** Table 11: Variable factor endowments                                                       ****
****                                                                                            ****
****                           Robustness results in appendix                                   ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
**** Table  A1: The effect of agricultural technological change on employment shares            ****
****            Observations are weighted by share of aggregate employment                      ****
**** Table  A2: Basic correlation in the data                                                   ****
****            Income per Capita and Services Employment Share                                 ****
**** Table  A3: The Effect of Agricultural Technical Change on                                  ****
****            Income per Capita and Services Employment Share                                 ****
**** Table  A4: The effect of technological change on agriculture                               ****
****            Robustness to controlling for additional initial municipality characteristics   ****
****            Panel A.                                                                        ****
****            Panel B.                                                                        ****
**** Table  A5: Effect of technological change on manufacturing                                 ****
****            Robustness to controlling for additional initial municipality characteristics   ****
**** Table  A6: The effect of agricultural technological change on manufacturing and migration  ****
****            Robustness to controlling for pre-existing trends                               ****
**** Table  A8: The effect of agricultural technological change on manufacturing                ****
****            Robustness to excluding sectors directly linked to soy and maize                ****
**** Table A10: The effect of technological change on agriculture. Soy and maize expansion      ****
****            Robustness to correcting standard errors for spatial correlation                ****
****            a.   Robust standard errors                                                     ****
****            b.   Standard errors clustered at micro-region level                            ****
****            c.   Standard errors clustered at meso-region level                             ****
****            d.   Conley's standard errors: cutoff at 50 Km                                  ****
****            e.   Conley's standard errors: cutoff at 100 Km                                 ****
****            f.   Conley's standard errors: cutoff at 200 Km                                 ****
**** Table A11: The effect of technological change on agriculture                               ****
****            Productivity, labor intensity and employment share                              ****
****            Robustness to correcting standard errors for spatial correlation                ****
****            a.   Robust standard errors                                                     ****
****            b.   Standard errors clustered at micro-region level                            ****
****            c.   Standard errors clustered at meso-region level                             ****
****            d.   Conley's standard errors: cutoff at 50 Km                                  ****
****            e.   Conley's standard errors: cutoff at 100 Km                                 ****
****            f.   Conley's standard errors: cutoff at 200 Km                                 ****
**** Table A12: The effect of agricultural technological change on manufacturing                ****
****            Employment share, employment and wages                                          ****
****            Robustness to correcting standard errors for spatial correlation                ****
****            a.   Robust standard errors                                                     ****
****            b.   Standard errors clustered at micro-region level                            ****
****            c.   Standard errors clustered at meso-region level                             ****
****            d.   Conley's standard errors: cutoff at 50 Km                                  ****
****            e.   Conley's standard errors: cutoff at 100 Km                                 ****
****            f.   Conley's standard errors: cutoff at 200 Km                                 ****
**** Table A13: The effect of technological change on agriculture and manufacturing             ****
****            Robustness to Alternative Definition of Technical Change                        ****
****                                                                                            ****
****____________________________________________________________________________________________****
**** Results with data at microregion level:                                                    ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
****                           Robustness results in appendix                                   ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
**** Table A7: The effect of agricultural technological change on manufacturing                 ****
****           Robustness to using a larger unit of observation: micro-regions                  ****
****                                                                                            ****
****____________________________________________________________________________________________****
**** Results with data at from the PIA industrial survey:                                       ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
****                           Robustness results in appendix                                   ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
**** Table A9: The effect of agricultural technological change on manufacturing                 ****
****           Robustness of results reported in Table 9 to controlling for commodity prices    ****
****************************************************************************************************

****************************************************************************************************
**** Table  1: Land use and labor intensity by agricultural activity                            ****
****************************************************************************************************
* The data for this table has been downloaded directly from the IBGE Sidra repository.
* To download tables from the 1996 and 2006 Agricultural Census go to: http://www.sidra.ibge.gov.br/
* See section A2 of the appendix for a detailed description of the data shown in this table.

****************************************************************************************************
**** Table  2: Summary Statistics of main variables at municipality level                       ****
****************************************************************************************************
cd "/Users/nicolaspolasek/Documents/Career/Education/PhD/ Berkeley ARE/Courses/ Spring 2023/ECON 270B/Replication Exercise/Replication data for Bustos et al. 2016/APST_ReplicationFiles"

use APST_AMC, replace

de
tabstat  soy_TA  mze_TA  gsoy_TA  nsoy_TA  log_PQ_LA      log_LA_TA , by(year) stat(N) 
tabstat dsoy_TA dmze_TA dgsoy_TA dnsoy_TA dlog_PQ_LA     dlog_LA_TA , by(year) stat(N)
tabstat  La_L  Lm_L  Ls_L  Lr_L         log_Lm           log_ym     , by(year) stat(N)
tabstat dLa_L dLm_L dLs_L dLr_L dLm0_L dlog_Lm dlog_Lm0 dlog_ym dlog_ym0, by(year)
tabstat  migration_rate A_soy_l A_soy_h A_mze_l A_mze_h dA_soy dA_mze dA_soy_p50 dA_soy_y2010 dA_mze_y2010 dA_soy2 dA_mze2 rural_adult log_y_pc_r alpha_adult log_pop_area log_ya_sct91 La_L_sct91 Lm_L_sct91, by(year)

* PANEL A: value per worker, labor intensity, soy area share, maize area share, GE soy area share
tabstat  log_PQ_LA	    log_LA_TA               if year == 1996 & rf  == 1, stat(mean sd  )
tabstat dlog_PQ_LA     dlog_LA_TA 	            if year == 2006 & rf  == 1, stat(mean sd N)
tabstat  soy_TA         mze_TA     gsoy_TA      if year == 1996 & fs  == 1, stat(mean sd N)
tabstat dsoy_TA        dmze_TA    dgsoy_TA      if year == 2006 & fs  == 1, stat(mean sd N)

* PANEL B: EMPLOYMENT SHARES
tabstat  La_L  Lm_L  Ls_L  Lr_L  log_Lm  log_ym if year == 2000 & rf  == 1, stat(mean sd  )	
tabstat dLa_L dLm_L dLs_L dLr_L dlog_Lm dlog_ym if year == 2010 & rf  == 1, stat(mean sd N)

* PANEL C: MIGRATION RATE
tabstat  migration_rate                         if year == 2000 & pre == 1, stat(mean sd N) 
tabstat  migration_rate                         if year == 2010 & rf  == 1, stat(mean sd N) 

* PANEL D: TECHNOLOGICAL CHANGE
tabstat A_soy_l A_soy_h A_mze_l A_mze_h dA_soy dA_mze if year == 2010 & rf== 1, stat(mean sd N) col(stat)

****************************************************************************************************
**** Table  3: Basic correlation in the data: agriculture                                       ****
****************************************************************************************************
reg dlog_PQ_LA     dsoy_TA_w     dmze_TA_w                if year == 2006 & ols == 1, r	
	outreg2 using Tables\Table3, ctitle("Change in log value per worker (2006-1996)") dec(3) nocons replace
reg dlog_LA_TA     dsoy_TA_w     dmze_TA_w       	if year == 2006 & ols == 1, r
	outreg2 using Tables\Table3, ctitle("Change in log labor intensity (2006-1996)")  dec(3) nocons append	
reg dLa_L        l.dsoy_TA_w   l.dmze_TA_w    	if year == 2010 & 	ols == 1, r
	outreg2 using Tables\Table3, ctitle("Change in employment share (2010-2000)")     dec(3) nocons append excel

****************************************************************************************************
**** Table  4: Basic correlation in the data: manufacturing                                     ****
****************************************************************************************************
reg dLm_L   l.dsoy_TA_w   l.dmze_TA_w   if year == 2010 & ols== 1, r
	outreg2 using Tables\Table4, ctitle("Change in Employment share (2010-2000)") dec(3) nocons replace
reg dlog_Lm l.dsoy_TA_w   l.dmze_TA_w   if year == 2010 & ols== 1, r
	outreg2 using Tables\Table4, ctitle("Change in Log employment (2010-2000)")   dec(3) nocons append
reg dlog_ym l.dsoy_TA_w   l.dmze_TA_w   if year == 2010 & ols== 1, r
	outreg2 using Tables\Table4, ctitle("Change in Log wage (2010-2000)")         dec(3) nocons append excel

****************************************************************************************************
**** Table  5: Comparing Municipalities below/above median increase in potential soy yield      ****
****************************************************************************************************
ttest La_L_sct91  , by(dA_soy_p50)           /* Note: in 1991 sector of employment was recorded with a different classification - here it is flagged as "_sct91" */
ttest Lm_L_sct91  , by(dA_soy_p50)           /* Note: in 1991 sector of employment was recorded with a different classification - here it is flagged as "_sct91" */
ttest rural_adult , by(dA_soy_p50)
ttest log_y_pc_r  , by(dA_soy_p50)
ttest log_pop_area, by(dA_soy_p50)
ttest alpha_adult , by(dA_soy_p50)

****************************************************************************************************
**** Table  6: The effect of technological change on agriculture. GE soy adoption               ****
****************************************************************************************************
reg dgsoy_TA_w   			dA_soy	 				l3.rural_adult						 if year ==2006 & fs== 1, r 
	outreg2 using Tables\Table6, ctitle("Change in GE Soy area share (2006-1996)") dec(3) nocons replace
reg dgsoy_TA_w   			dA_soy	 				l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult   if year ==2006 & fs== 1, r 
	outreg2 using Tables\Table6, ctitle(" ") dec(3) nocons append
reg dnsoy_TA_w   			dA_soy  				l3.rural_adult					     if year ==2006 & fs== 1, r       
	outreg2 using Tables\Table6, ctitle("Change in Non-GE Soy area share (2006-1996)") dec(3) nocons append
reg dnsoy_TA_w   			dA_soy  				l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult   if year ==2006 & fs== 1, r       
	outreg2 using Tables\Table6, ctitle(" ") dec(3) nocons append excel

****************************************************************************************************
**** Table  7: The effect of technological change on agriculture. Soy and maize expansion       ****
****************************************************************************************************
reg dsoy_TA_w   			dA_soy			       	l3.rural_adult					    if year ==2006 & fs== 1, r
	outreg2 using Tables\Table7, ctitle("Change in Soy area share (2006-1996)")	                                    dec(3) nocons replace
reg dsoy_TA_w   			dA_soy  		dA_mze	l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult  if year ==2006 & fs== 1, r
	outreg2 using Tables\Table7, ctitle(" ") 	                                    dec(3) nocons append
reg dmze_TA_w   			       	        dA_mze  l3.rural_adult				     	if year ==2006 & fs== 1, r
	outreg2 using Tables\Table7, ctitle("Change in Maize area share (2006-1996)")	                                    dec(3) nocons append
reg dmze_TA_w   			dA_soy			dA_mze 	l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult	if year ==2006 & fs== 1, r
	outreg2 using Tables\Table7, ctitle(" ") dec(3) nocons append excel sortvar(dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult)

****************************************************************************************************
**** Table  8: The effect of technological change on agriculture                                ****
****           Productivity, labor intensity and employment share                               ****
****************************************************************************************************
reg dlog_PQ_LA         	dA_soy 			dA_mze 	l3.rural_adult						if year == 2006 & rf== 1, r
	outreg2 using Tables\Table8, ctitle("Change in Log value per worker (2006-1996)") dec(3) nocons replace
reg dlog_PQ_LA         	dA_soy 			dA_mze 	l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult 	if year == 2006 & rf== 1, r
	outreg2 using Tables\Table8, ctitle(" ") dec(3) nocons append
reg dlog_LA_TA          	dA_soy 			dA_mze 	l3.rural_adult		 				if year == 2006 & rf== 1, r
	outreg2 using Tables\Table8, ctitle("Change in Log labor intensity (2006-1996)")  dec(3) nocons append
reg dlog_LA_TA          	dA_soy 			dA_mze 	l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult 	if year == 2006 & rf== 1, r
	outreg2 using Tables\Table8, ctitle(" ")  dec(3) nocons append
reg dLa_L			dA_soy 			dA_mze 	l4.rural_adult 			    	 		if year == 2010 &   rf== 1, r
	outreg2 using Tables\Table8, ctitle("Change in Employment share (2010-2000)") 	  dec(3) nocons append
reg dLa_L   			dA_soy  		dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & 	rf== 1, r
	outreg2 using Tables\Table8, ctitle(" ")  dec(3) nocons append excel

****************************************************************************************************
**** Table  9: The effect of agricultural technological change on manufacturing                 ****
****           Employment share, employment and wages                                           ****
****************************************************************************************************
reg dLm_L  dA_soy dA_mze l4.rural_adult  					if year == 2010 & rf == 1 , r
	outreg2 using Tables\Table9, ctitle("Change in Employment share (2010-2000)") dec(3) nocons replace
reg dLm_L  dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult   if year == 2010 & rf == 1 , r
	outreg2 using Tables\Table9, ctitle(" ") 	    dec(3) nocons append
reg dlog_Lm   dA_soy dA_mze l4.rural_adult 					if year == 2010 & rf == 1 , r
	outreg2 using Tables\Table9, ctitle("Change in Log employment (2010-2000)")   dec(3) nocons append
reg dlog_Lm   dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 , r
	outreg2 using Tables\Table9, ctitle(" ") 		dec(3) nocons append
reg dlog_ym dA_soy dA_mze l4.rural_adult 					if year == 2010 & rf == 1 , r
	outreg2 using Tables\Table9, ctitle("Change in Log wage (2010-2000)")         dec(3) nocons append
reg dlog_ym dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1 , r
	outreg2 using Tables\Table9, ctitle(" ") 				                        dec(3) nocons append excel

****************************************************************************************************
**** Table 10: The effect of agricultural technological change on employment shares             ****
****************************************************************************************************
reg dLa_L dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 , r
	outreg2 using Tables\Table10, ctitle("Change in Agriculture, Employment share (2010-2000)") 	    dec(3) nocons replace
reg dLm_L dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1  , r
	outreg2 using Tables\Table10, ctitle("Change in Manufacturing, Employment share (2010-2000)") 	    dec(3) nocons append
reg dLs_L dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1  , r
	outreg2 using Tables\Table10, ctitle("Change in Services, Employment share (2010-2000)") 	    	dec(3) nocons append
reg dLr_L dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 , r
	outreg2 using Tables\Table10, ctitle("Change in Other Sectors, Employment share (2010-2000)") 	    dec(3) nocons append excel

****************************************************************************************************
**** Table 11: Variable factor endowments                                                       ****
****************************************************************************************************
reg migration_rate    dA_soy      dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1, r
	outreg2 using Tables\Table11, ctitle("	, All") dec(3) nocons  replace
reg migration_rate    dA_soy      dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 & frontier == 0, r
	outreg2 using Tables\Table11, ctitle("Migration rate (2010-2000), Non-Frontier") dec(3) nocons  append
reg migration_rate    dA_soy      dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 & frontier == 1, r
	outreg2 using Tables\Table11, ctitle(" , Frontier") dec(3) nocons  append
reg dLa_L dA_soy      dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 & frontier == 0, r
	outreg2 using Tables\Table11, ctitle("Change in Agri Empl. Share (2010-2000), Non-Frontier") dec(3) nocons  append
reg dLa_L dA_soy      dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 & frontier == 1, r
	outreg2 using Tables\Table11, ctitle(" , Frontier") dec(3) nocons  append
reg dLm_L dA_soy      dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 & frontier == 0, r
	outreg2 using Tables\Table11, ctitle("Change in Manuf Empl. Share (2010-2000), Non-Frontier") dec(3) nocons  append
reg dLm_L dA_soy      dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 & rf == 1 & frontier == 1, r
	outreg2 using Tables\Table11, ctitle(" , Frontier") dec(3) nocons  append excel
	
****************************************************************************************************
****                           Robustness results in appendix                                   ****
****ØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØØ****
**** Table  A1: The effect of agricultural technological change on employment shares            ****
****            Observations are weighted by share of aggregate employment                      ****
****************************************************************************************************
reg dlog_PQ_LA     dA_soy dA_mze  l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & f.rf == 1 [pw=f.weight], r
	outreg2 using Tables\TableA1, ctitle("Change in log output per, worker (2006-1996)") 	        dec(3) nocons replace
reg dLa_L          dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 &   rf == 1 [pw=weight], r
	outreg2 using Tables\TableA1, ctitle("Change in Agriculture, Employment share (2010-2000)") 	dec(3) nocons append
reg dLm_L          dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 &   rf == 1 [pw=weight], r
	outreg2 using Tables\TableA1, ctitle("Change in Manufacturing, Employment share (2010-2000)") 	dec(3) nocons append
reg dLs_L          dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 &   rf == 1 [pw=weight], r
	outreg2 using Tables\TableA1, ctitle("Change in Services, Employment share (2010-2000)") 	    dec(3) nocons append
reg dLr_L          dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year == 2010 &   rf == 1 [pw=weight], r
	outreg2 using Tables\TableA1, ctitle("Change in Other Sectors, Employment share (2010-2000)") 	dec(3) nocons append excel

****************************************************************************************************
**** Table  A2: Basic correlation in the data                                                   ****
****            Income per Capita and Services Employment Share                                 ****
****************************************************************************************************
reg dlog_y                     l.dsoy_TA_w   l.dmze_TA_w               if year == 2010 & ols==1, r
	outreg2 using Tables\TableA2, ctitle("Change in income, per capita (2010-2000)")         dec( 3 ) nocons replace
reg dLs_L                      l.dsoy_TA_w   l.dmze_TA_w               if year == 2010 & ols==1, r
	outreg2 using Tables\TableA2, ctitle("Change in Services, Employment share (2010-2000)") dec( 3 ) nocons append
reg dlog_y l.dsoy_TA_w_FamSh   l.dsoy_TA_w   l.dmze_TA_w   l.soy_FamSh if year == 2010 & ols==1, r
	outreg2 using Tables\TableA2, ctitle("Change in income, per capita (2010-2000)")         dec( 3 ) nocons append
reg dLs_L  l.dsoy_TA_w_FamSh   l.dsoy_TA_w   l.dmze_TA_w   l.soy_FamSh if year == 2010 & ols==1, r
	outreg2 using Tables\TableA2, ctitle("Change in Services, Employment share (2010-2000)") dec( 3 ) nocons append excel sortvar(l.dsoy_TA_w_FamSh l.dsoy_TA_w   l.dmze_TA_w   l.soy_FamSh)

****************************************************************************************************
**** Table  A3: The Effect of Agricultural Technical Change on                                  ****
****            Income per Capita and Services Employment Share                                 ****
****************************************************************************************************
reg dlog_y                dA_soy dA_mze             l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf==1, r
	outreg2 using Tables\TableA3, ctitle("Change in income, per capita (2010-2000)")         dec( 3 ) nocons replace
reg dLs_L                 dA_soy dA_mze             l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf==1, r
	outreg2 using Tables\TableA3, ctitle("Change in Services, Employment share (2010-2000)") dec( 3 ) nocons append
reg dlog_y l.dA_soy_FamSh dA_soy dA_mze l.soy_FamSh l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf==1, r
	outreg2 using Tables\TableA3, ctitle("Change in income, per capita (2010-2000)")         dec( 3 ) nocons append
reg dLs_L  l.dA_soy_FamSh dA_soy dA_mze l.soy_FamSh l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf==1, r
	outreg2 using Tables\TableA3, ctitle("Change in Services, Employment share (2010-2000)") dec( 3 ) nocons append excel sortvar(l.dA_soy_FamSh dA_soy dA_mze l.soy_FamSh)

****************************************************************************************************
**** Table  A4: The effect of technological change on agriculture                               ****
****            Robustness to controlling for additional initial municipality characteristics   ****
****            Panel A.                                                                        ****
****************************************************************************************************
reg dsoy_TA_w      dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult l4.log_PQ_LA                          	    if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelA, ctitle(" ")                                       dec(3) nocons replace
reg dsoy_TA_w      dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult              l3.log_ya_sct91            	if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelA, ctitle("Change in Soy area, share (2006-1996)")   dec(3) nocons append
reg dsoy_TA_w      dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult                            l3.La_L_sct91	if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelA, ctitle(" ")                                       dec(3) nocons append
reg dmze_TA_w      dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult l4.log_PQ_LA                          	    if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelA, ctitle(" ")                                       dec(3) nocons append
reg dmze_TA_w      dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult              l3.log_ya_sct91            	if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelA, ctitle("Change in Maize area, share (2006-1996)") dec(3) nocons append
reg dmze_TA_w      dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult                            l3.La_L_sct91	if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelA, ctitle(" ")                                       dec(3) nocons append excel sortvar(dA_soy dA_mze l4.log_PQ_LA l3.log_ya_sct91 l3.La_L_sct91)

	
****************************************************************************************************
****            Panel B.                                                                        ****
****************************************************************************************************
reg dlog_PQ_LA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult l4.log_PQ_LA                               if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle(" ")                                          dec(3) nocons replace
reg dlog_PQ_LA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult              l3.log_ya_sct91               if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle("Change in Log value per worker (2006-1996)") dec(3) nocons append	
reg dlog_PQ_LA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult                            l3.La_L_sct91	if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle(" ")                                          dec(3) nocons append
reg dlog_LA_TA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult l4.log_PQ_LA                               if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle(" ")                                          dec(3) nocons append
reg dlog_LA_TA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult              l3.log_ya_sct91               if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle("Change in Log labor intensity (2006-1996)")  dec(3) nocons append
reg dlog_LA_TA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult                            l3.La_L_sct91	if year == 2006 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle(" ")                                          dec(3) nocons append
reg dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult l3.log_PQ_LA                               if year == 2010 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle(" ")                                          dec(3) nocons append
reg dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult              l4.log_ya_sct91               if year == 2010 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle("Change in Employment share (2010-2000)") 	   dec(3) nocons append
reg dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult                            l4.La_L_sct91   if year == 2010 & rf== 1, r
	outreg2 using Tables\TableA4_PanelB, ctitle(" ")                                          dec(3) nocons append excel sortvar(dA_soy dA_mze l4.log_PQ_LA l3.log_ya_sct91 l3.La_L_sct91 l3.log_PQ_LA l4.log_ya_sct91 l4.La_L_sct91)
	
****************************************************************************************************
**** Table  A5: Effect of technological change on manufacturing                                 ****
****            Robustness to controlling for additional initial municipality characteristics   ****
****************************************************************************************************
reg dLm_L   dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult l3.log_PQ_LA                             if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle(" ")                                      dec(3) nocons replace
reg dLm_L   dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult              l4.log_ya_sct91             if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle("Change in Employment share (2010-2000)") dec(3) nocons append
reg dLm_L   dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult                            l4.La_L_sct91 if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle(" ")                                      dec(3) nocons append
reg dlog_Lm dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult l3.log_PQ_LA                             if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle(" ")                                      dec(3) nocons append
reg dlog_Lm dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult              l4.log_ya_sct91             if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle("Change in Log employment (2010-2000)")   dec(3) nocons append
reg dlog_Lm dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult                            l4.La_L_sct91 if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle(" ")                                      dec(3) nocons append
reg dlog_ym dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult l3.log_PQ_LA                             if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle(" ")                                      dec(3) nocons append
reg dlog_ym dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult              l4.log_ya_sct91             if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle("Change in Log wage (2010-2000)")         dec(3) nocons append
reg dlog_ym dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult                            l4.La_L_sct91 if year == 2010 & rf == 1 , r
	outreg2 using Tables\TableA5, ctitle(" ")                                      dec(3) nocons append excel sortvar(dA_soy dA_mze l3.log_PQ_LA l4.log_ya_sct91 l4.La_L_sct91)
		
****************************************************************************************************
**** Table  A6: The effect of agricultural technological change on manufacturing and migration  ****
****            Robustness to controlling for pre-existing trends                               ****
****************************************************************************************************
reg dlog_Lm        dA_soy_y2010 dA_mze_y2010 dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult y2010 if pre == 1, r
	outreg2 using Tables\TableA6, ctitle("Change in Log employment (2010-1991)") dec(3) nocons replace
reg dlog_ym        dA_soy_y2010 dA_mze_y2010 dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult y2010 if pre == 1, r
	outreg2 using Tables\TableA6, ctitle("Change in Log wage (2010-1991)")       dec(3) nocons append
reg migration_rate dA_soy_y2010 dA_mze_y2010 dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult y2010 if pre == 1, r
	outreg2 using Tables\TableA6, ctitle("Migration rate (2010-1991)")            dec(3) nocons append excel

****************************************************************************************************
**** Table  A8: The effect of agricultural technological change on manufacturing                ****
****            Robustness to excluding sectors directly linked to soy and maize                ****
****************************************************************************************************
reg dLm0_L dA_soy dA_mze   l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010  & rf== 1, r
		outreg2 using Tables\TableA8, ctitle("Change in Employment share (2010-2000)") dec(3) nocons  replace
reg dlog_Lm0   dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf== 1, r
		outreg2 using Tables\TableA8, ctitle("Change in Log employment (2010-2000)")   dec(3) nocons  append
reg dlog_ym0 dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010  & rf== 1, r
		outreg2 using Tables\TableA8, ctitle("Change in Log wage (2010-2000)")         dec(3) nocons  append excel

****************************************************************************************************
**** Table A10: The effect of technological change on agriculture. Soy and maize expansion      ****
****            Robustness to correcting standard errors for spatial correlation                ****
****            a.   Robust standard errors                                                     ****
****************************************************************************************************
reg dsoy_TA_w   dA_soy        l3.rural_adult		                                      if year ==2006 & fs == 1 & meso!=. & micro!=., r
   outreg2 using Tables\TableA10a, ctitle("Change in Soy area share (2006-1996)") 	 dec(3)  nocons asterisk(se) replace
reg dsoy_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year ==2006 & fs == 1 & meso!=. & micro!=., r
   outreg2 using Tables\TableA10a, ctitle(" ") 	                                 dec(3)  nocons asterisk(se) append
reg dmze_TA_w   dA_mze 	      l3.rural_adult		                                      if year ==2006 & fs == 1 & meso!=. & micro!=., r
   outreg2 using Tables\TableA10a, ctitle("Change in Maize area share (2006-1996)") dec(3)  nocons asterisk(se) append
reg dmze_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year ==2006 & fs == 1 & meso!=. & micro!=., r
   outreg2 using Tables\TableA10a, ctitle(" ")                                      dec(3)  nocons asterisk(se) append sortvar(dA_soy	    dA_mze 	   l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult)  excel

****************************************************************************************************
****            b.   Standard errors clustered at micro-region level                            ****
****************************************************************************************************
reg dsoy_TA_w   dA_soy        l3.rural_adult		                                      if year ==2006 & fs == 1 & meso!=. & micro!=., cluster(micro)
   outreg2 using Tables\TableA10b, ctitle("Change in Soy area share (2006-1996)") 	 dec(3)  nocons asterisk(se) replace
reg dsoy_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year ==2006 & fs == 1 & meso!=. & micro!=., cluster(micro)
   outreg2 using Tables\TableA10b, ctitle(" ") 	                                 dec(3)  nocons asterisk(se) append
reg dmze_TA_w   dA_mze 	      l3.rural_adult		                                      if year ==2006 & fs == 1 & meso!=. & micro!=., cluster(micro)
   outreg2 using Tables\TableA10b, ctitle("Change in Maize area share (2006-1996)") dec(3)  nocons asterisk(se) append
reg dmze_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year ==2006 & fs == 1 & meso!=. & micro!=., cluster(micro)
   outreg2 using Tables\TableA10b, ctitle(" ")                                      dec(3)  nocons asterisk(se) append sortvar(dA_soy	    dA_mze 	   l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult)  excel

****************************************************************************************************
****            c.   Standard errors clustered at meso-region level                             ****
****************************************************************************************************
reg dsoy_TA_w   dA_soy        l3.rural_adult		                                      if year ==2006 & fs == 1 & meso!=. & micro!=., cluster(meso)
   outreg2 using Tables\TableA10c, ctitle("Change in Soy area share (2006-1996)") 	 dec(3)  nocons asterisk(se) replace
reg dsoy_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year ==2006 & fs == 1 & meso!=. & micro!=., cluster(meso)
   outreg2 using Tables\TableA10c, ctitle(" ") 	                                 dec(3)  nocons asterisk(se) append
reg dmze_TA_w   dA_mze        l3.rural_adult		                                      if year ==2006 & fs == 1 & meso!=. & micro!=., cluster(meso)
   outreg2 using Tables\TableA10c, ctitle("Change in Maize area share (2006-1996)") dec(3)  nocons asterisk(se) append
reg dmze_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year ==2006 & fs == 1 & meso!=. & micro!=., cluster(meso)
   outreg2 using Tables\TableA10c, ctitle(" ")                                      dec(3)  nocons asterisk(se) append sortvar(dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult) excel

****************************************************************************************************
****            d.   Conley's standard errors: cutoff at 50 Km                                  ****
****************************************************************************************************
capture program drop ols_spatial_HAC
run ols_spatial_HAC.ado             /* This runs the program needed to compute spatial s.e. */

ols_spatial_HAC dsoy_TA_w   dA_soy        l3.rural_adult		                                      constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett
   outreg2 using Tables\TableA10d, ctitle("Change in Soy area share (2006-1996)")   dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dsoy_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett
   outreg2 using Tables\TableA10d, ctitle(" ") 	                                 dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dmze_TA_w          dA_mze l3.rural_adult                                              constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett
   outreg2 using Tables\TableA10d, ctitle("Change in Maize area share (2006-1996)") dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dmze_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett
   outreg2 using Tables\TableA10d, ctitle(" ")                                      dec(3)  drop(constant) nonotes label asterisk(se) append excel sortvar(dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult) 

****************************************************************************************************
****            e.   Conley's standard errors: cutoff at 100 Km                                 ****
****************************************************************************************************
ols_spatial_HAC dsoy_TA_w   dA_soy        l3.rural_adult		                                      constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett
   outreg2 using Tables\TableA10e, ctitle("Change in Soy area share (2006-1996)")   dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dsoy_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett
   outreg2 using Tables\TableA10e, ctitle(" ") 	                                 dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dmze_TA_w          dA_mze l3.rural_adult                                              constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett
   outreg2 using Tables\TableA10e, ctitle("Change in Maize area share (2006-1996)") dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dmze_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett
   outreg2 using Tables\TableA10e, ctitle(" ")                                      dec(3)  drop(constant) nonotes label asterisk(se) append excel sortvar(dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult) 
   
****************************************************************************************************
****            f.   Conley's standard errors: cutoff at 200 Km                                 ****
****************************************************************************************************
ols_spatial_HAC dsoy_TA_w   dA_soy        l3.rural_adult		                                      constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett
   outreg2 using Tables\TableA10f, ctitle("Change in Soy area share (2006-1996)")   dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dsoy_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett
   outreg2 using Tables\TableA10f, ctitle(" ") 	                                 dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dmze_TA_w          dA_mze l3.rural_adult                                              constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett
   outreg2 using Tables\TableA10f, ctitle("Change in Maize area share (2006-1996)") dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dmze_TA_w   dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year ==2006 & fs ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett
   outreg2 using Tables\TableA10f, ctitle(" ")                                      dec(3)  drop(constant) nonotes label asterisk(se) append excel sortvar(dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult) 

   
****************************************************************************************************
**** Table A11: The effect of technological change on agriculture                               ****
****            Productivity, labor intensity and employment share                              ****
****            Robustness to correcting standard errors for spatial correlation                ****
****            a.   Robust standard errors                                                     ****
****************************************************************************************************
reg dlog_PQ_LA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & rf == 1 & meso!=. & micro!=., r
	outreg2 using Tables\TableA11a,     ctitle("Change in Log value per worker (2006-1996)") dec(3) nocons asterisk(se) replace	
reg dlog_LA_TA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & rf == 1 & meso!=. & micro!=., r
	outreg2 using Tables\TableA11a,     ctitle("Change in Log labor intensity (2006-1996)")  dec(3) nocons asterisk(se) append
reg dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1 & meso!=. & micro!=., r
	outreg2 using Tables\TableA11a,     ctitle("Change in Employment share (2010-2000)")     dec(3) nocons asterisk(se) append excel

****************************************************************************************************
****            b.   Standard errors clustered at micro-region level                            ****
****************************************************************************************************
reg dlog_PQ_LA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & rf == 1 & meso!=. & micro!=., cluster(micro)
	outreg2 using Tables\TableA11b,     ctitle("Change in Log value per worker (2006-1996)") dec(3) nocons asterisk(se) replace	
reg dlog_LA_TA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & rf == 1 & meso!=. & micro!=., cluster(micro)
	outreg2 using Tables\TableA11b,     ctitle("Change in Log labor intensity (2006-1996)")  dec(3) nocons asterisk(se) append
reg dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1 & meso!=. & micro!=., cluster(micro)
	outreg2 using Tables\TableA11b,     ctitle("Change in Employment share (2010-2000)")     dec(3) nocons asterisk(se) append excel
	
****************************************************************************************************
****            c.   Standard errors clustered at meso-region level                             ****
****************************************************************************************************
reg dlog_PQ_LA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & rf == 1 & meso!=. & micro!=., cluster(meso)
	outreg2 using Tables\TableA11c,     ctitle("Change in Log value per worker (2006-1996)") dec(3) nocons asterisk(se) replace	
reg dlog_LA_TA     dA_soy dA_mze l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & rf == 1 & meso!=. & micro!=., cluster(meso)
	outreg2 using Tables\TableA11c,     ctitle("Change in Log labor intensity (2006-1996)")  dec(3) nocons asterisk(se) append
reg dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1 & meso!=. & micro!=., cluster(meso)
	outreg2 using Tables\TableA11c,     ctitle("Change in Employment share (2010-2000)")     dec(3) nocons asterisk(se) append excel

****************************************************************************************************
****            d.   Conley's standard errors: cutoff at 50 Km                                  ****
****************************************************************************************************
ols_spatial_HAC dlog_PQ_LA     dA_soy dA_mze l3.rural_adult	l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year == 2006 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett 
   outreg2 using Tables\TableA11d, ctitle("Change in Log value per worker (2006-1996)") dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dlog_LA_TA     dA_soy dA_mze l3.rural_adult	l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year == 2006 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett 
   outreg2 using Tables\TableA11d, ctitle("Change in Log labor intensity (2006-1996)")  dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett 
   outreg2 using Tables\TableA11d, ctitle("Change in Employment share (2010-2000)")     dec(3)  drop(constant) nonotes label asterisk(se) append excel 

****************************************************************************************************
****            e.   Conley's standard errors: cutoff at 100 Km                                 ****
****************************************************************************************************
ols_spatial_HAC dlog_PQ_LA     dA_soy dA_mze l3.rural_adult	l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year == 2006 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett 
   outreg2 using Tables\TableA11e, ctitle("Change in Log value per worker (2006-1996)") dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dlog_LA_TA     dA_soy dA_mze l3.rural_adult	l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year == 2006 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett 
   outreg2 using Tables\TableA11e, ctitle("Change in Log labor intensity (2006-1996)")  dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett 
   outreg2 using Tables\TableA11e, ctitle("Change in Employment share (2010-2000)")     dec(3)  drop(constant) nonotes label asterisk(se) append excel 

****************************************************************************************************
****            f.   Conley's standard errors: cutoff at 200 Km                                 ****
****************************************************************************************************
ols_spatial_HAC dlog_PQ_LA     dA_soy dA_mze l3.rural_adult	l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year == 2006 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett 
   outreg2 using Tables\TableA11f, ctitle("Change in Log value per worker (2006-1996)") dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dlog_LA_TA     dA_soy dA_mze l3.rural_adult	l3.log_y_pc_r l3.log_pop_area l3.alpha_adult constant if year == 2006 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett 
   outreg2 using Tables\TableA11f, ctitle("Change in Log labor intensity (2006-1996)")  dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dLa_L          dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1 & meso!=. & micro!=., lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett 
   outreg2 using Tables\TableA11f, ctitle("Change in Employment share (2010-2000)")     dec(3)  drop(constant) nonotes label asterisk(se) append excel 
	
****************************************************************************************************
**** Table A12: The effect of agricultural technological change on manufacturing                ****
****            Employment share, employment and wages                                          ****
****            Robustness to correcting standard errors for spatial correlation                ****
****            a.   Robust standard errors                                                     ****
****************************************************************************************************
reg dLm_L   dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, r
	outreg2 using Tables\TableA12a,     ctitle("Change in Employment share (2010-2000)") dec(3)  nocons asterisk(se) replace
reg dlog_Lm dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, r
	outreg2 using Tables\TableA12a,     ctitle("Change in Log employment (2010-2000)")   dec(3)  nocons asterisk(se) append
reg dlog_ym dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, r
	outreg2 using Tables\TableA12a,     ctitle("Change in Log wage (2010-2000)")         dec(3)  nocons asterisk(se) append excel

****************************************************************************************************
****            b.   Standard errors clustered at micro-region level                            ****
****************************************************************************************************
reg dLm_L   dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, cluster(micro)
	outreg2 using Tables\TableA12b,     ctitle("Change in Employment share (2010-2000)") dec(3)  nocons asterisk(se) replace
reg dlog_Lm dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, cluster(micro)
	outreg2 using Tables\TableA12b,     ctitle("Change in Log employment (2010-2000)")   dec(3)  nocons asterisk(se) append
reg dlog_ym dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, cluster(micro)
	outreg2 using Tables\TableA12b,     ctitle("Change in Log wage (2010-2000)")         dec(3)  nocons asterisk(se) append excel

****************************************************************************************************
****            c.   Standard errors clustered at meso-region level                             ****
****************************************************************************************************
reg dLm_L   dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, cluster(meso)
	outreg2 using Tables\TableA12c,     ctitle("Change in Employment share (2010-2000)") dec(3)  nocons asterisk(se) replace
reg dlog_Lm dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, cluster(meso)
	outreg2 using Tables\TableA12c,     ctitle("Change in Log employment (2010-2000)")   dec(3)  nocons asterisk(se) append
reg dlog_ym dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, cluster(meso)
	outreg2 using Tables\TableA12c,     ctitle("Change in Log wage (2010-2000)")         dec(3)  nocons asterisk(se) append excel

****************************************************************************************************
****            d.   Conley's standard errors: cutoff at 50 Km                                  ****
****************************************************************************************************
ols_spatial_HAC dLm_L   dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett
   outreg2 using Tables\TableA12d, ctitle("Change in Employment share (2010-2000)") dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dlog_Lm dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett
   outreg2 using Tables\TableA12d, ctitle("Change in Log employment (2010-2000)")   dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dlog_ym dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist( 50) dropvar bartlett
   outreg2 using Tables\TableA12d, ctitle("Change in Log wage (2010-2000)")         dec(3)  drop(constant) nonotes label asterisk(se) append excel

****************************************************************************************************
****            e.   Conley's standard errors: cutoff at 100 Km                                 ****
****************************************************************************************************
ols_spatial_HAC dLm_L   dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett
   outreg2 using Tables\TableA12e, ctitle("Change in Employment share (2010-2000)") dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dlog_Lm dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett
   outreg2 using Tables\TableA12e, ctitle("Change in Log employment (2010-2000)")   dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dlog_ym dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(100) dropvar bartlett
   outreg2 using Tables\TableA12e, ctitle("Change in Log wage (2010-2000)")         dec(3)  drop(constant) nonotes label asterisk(se) append excel

****************************************************************************************************
****            f.   Conley's standard errors: cutoff at 200 Km                                 ****
****************************************************************************************************
ols_spatial_HAC dLm_L   dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett
   outreg2 using Tables\TableA12f, ctitle("Change in Employment share (2010-2000)") dec(3)  drop(constant) nonotes label asterisk(se) replace
ols_spatial_HAC dlog_Lm dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett
   outreg2 using Tables\TableA12f, ctitle("Change in Log employment (2010-2000)")   dec(3)  drop(constant) nonotes label asterisk(se) append
ols_spatial_HAC dlog_ym dA_soy dA_mze l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult constant if year == 2010 & rf ==1, lat(latitude) lon(longitude) timevar(time) panelvar(AMC) dist(200) dropvar bartlett
   outreg2 using Tables\TableA12f, ctitle("Change in Log wage (2010-2000)")         dec(3)  drop(constant) nonotes label asterisk(se) append excel

****************************************************************************************************
**** Table A13: The effect of technological change on agriculture and manufacturing             ****
****            Robustness to Alternative Definition of Technical Change                        ****
****************************************************************************************************
reg dsoy_TA_w      dA_soy2 dA_mze2 l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & fs == 1, r
	outreg2 using Tables\TableA13, ctitle("Change in Soy area share")	      dec(3) nocons nonotes replace label
reg dmze_TA_w      dA_soy2 dA_mze2 l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & fs == 1, r
	outreg2 using Tables\TableA13, ctitle("Change in Maize area share")	  dec(3) nocons nonotes append  label
reg dlog_PQ_LA     dA_soy2 dA_mze2 l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & rf == 1, r
	outreg2 using Tables\TableA13, ctitle("Change in Log value per worker") dec(3) nocons nonotes append  label
reg dlog_LA_TA     dA_soy2 dA_mze2 l3.rural_adult l3.log_y_pc_r l3.log_pop_area l3.alpha_adult if year == 2006 & rf == 1, r
	outreg2 using Tables\TableA13, ctitle("Change in Log labor intensity")  dec(3) nocons nonotes append  label
reg dLa_L          dA_soy2 dA_mze2 l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, r
	outreg2 using Tables\TableA13, ctitle("Change in Employment share")	  dec(3) nocons nonotes append  label
reg dLm_L          dA_soy2 dA_mze2 l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, r
	outreg2 using Tables\TableA13, ctitle("Change in Employment share")	  dec(3) nocons nonotes append  label
reg dlog_Lm        dA_soy2 dA_mze2 l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, r
	outreg2 using Tables\TableA13, ctitle("Change in Log Employment")	      dec(3) nocons nonotes append  label
reg dlog_ym        dA_soy2 dA_mze2 l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult if year == 2010 & rf == 1, r
	outreg2 using Tables\TableA13, ctitle("Change in Log wage")	          dec(3) nocons nonotes append  label excel

****************************************************************************************************
**** Table A7: The effect of agricultural technological change on manufacturing                 ****
****           Robustness to using a larger unit of observation: micro-regions                  ****
****************************************************************************************************
use APST_micro, replace
reg dLm_L   dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year==2010, r
	outreg2 using Tables\TableA7, ctitle("Change in Employment share (2010-2000)") dec(3) nocons  replace
reg dlog_Lm dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year==2010, r
	outreg2 using Tables\TableA7, ctitle("Change in Log employment (2010-2000)")   dec(3) nocons  append
reg dlog_ym dA_soy dA_mze  l4.rural_adult l4.log_y_pc_r l4.log_pop_area l4.alpha_adult  if year==2010, r
	outreg2 using Tables\TableA7, ctitle("Change in Log wage (2010-2000)")         dec(3) nocons  append excel

****************************************************************************************************
**** Table A9: The effect of agricultural technological change on manufacturing                 ****
****           Robustness of results reported in Table 9 to controlling for commodity prices    ****
****************************************************************************************************
* The data used for the regressions reported on Table A9 has been provided by the Brazilian Statistical 
* Office and is confidential. It therefore cannot be posted on the AER website. Here we post the code 
* used to estimate the regressions reported in table A9. We explain data construction in the appendix.

/* 
use PIA Database 

gen     A_soy         = cond(year <  2003,A_soy_l, ///
                        cond(year >= 2003,A_soy_h,.))
gen     A_mze         = cond(year <  2003,A_mze_l, ///
                        cond(year >= 2003,A_mze_h,.))
gen     pA_soy        = p_soybean  * A_soy_l
gen     pA_mze        = p_maize    * A_mze_l

for X in var rural_adult log_y_pc_r log_pop_area alpha_adult :  for Y in num 1996/2007 : replace X91_t = X91_t * (Y-1995) if year == Y

xi: areg log_L_end_ul_manuf_P30 A_soy A_mze               rural_adult91_t	                                                 i.year if year < 2008, absorb(AMC) cluster(AMC)
	outreg2 using RF-PIA, dec(3) nocons ctitle(" ")                    replace drop(_Iy*)
xi: areg log_L_end_ul_manuf_P30 A_soy A_mze pA_soy pA_mze rural_adult91_t	                                                 i.year if year < 2008, absorb(AMC) cluster(AMC)
	outreg2 using RF-PIA, dec(3) nocons ctitle("Log Total Employment") append  drop(_Iy*)
xi: areg log_L_end_ul_manuf_P30 A_soy A_mze pA_soy pA_mze rural_adult91_t	alpha_adult91_t log_pop_area91_t log_y_pc_r91_t  i.year if year < 2008, absorb(AMC) cluster(AMC)
	outreg2 using RF-PIA, dec(3) nocons ctitle(" ")                    append  drop(_Iy*)
xi: areg log_W_L_ul_manuf_P30   A_soy A_mze               rural_adult91_t	                                                 i.year if year < 2008, absorb(AMC) cluster(AMC)
	outreg2 using RF-PIA, dec(3) nocons ctitle(" ")                    append  drop(_Iy*)
xi: areg log_W_L_ul_manuf_P30   A_soy A_mze pA_soy pA_mze rural_adult91_t	                                                 i.year if year < 2008, absorb(AMC) cluster(AMC)
	outreg2 using RF-PIA, dec(3) nocons ctitle("Log Wage")             append  drop(_Iy*)
xi: areg log_W_L_ul_manuf_P30   A_soy A_mze pA_soy pA_mze rural_adult91_t	alpha_adult91_t log_pop_area91_t log_y_pc_r91_t  i.year if year < 2008, absorb(AMC) cluster(AMC)	
	outreg2 using RF-PIA, dec(3) nocons ctitle(" ")                    append  drop(_Iy*) sortvar(A_soy A_mze rural_adult91_t)	
*/
	
log close	
exit
